<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<title>百家乐</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0 user-scalable=no">
		<%@include file="/WEB-INF/base.jspf"%>
		<script src="/js/font_595888_1jlcfz62jg8vkj4i.js"></script>
		<style type="text/css">
		header {
		background-color: black;
		color:white;}
		body {
			background-color: #003d38;
		}
		.site-background {
			background-image: url(/img/caizhong/bjl/bjlbg.png);
			max-height: 100%;
			max-width: 100%;
			opacity: 0.08; 
			filter:alpha(opacity=8);	
			position: fixed;
			top: 0;
			left: 0;
			bottom: 0;
			right: 0;
		}
		
		header {
		display:flex;
		padding: 1vh 0;
		justify-content: center;
		position: relative;}
		.div-c-main {
			display: flex;
			height: 100vh;
			width: 100%;
			flex-direction: column;
			position: fixed;
		}
		.div-c-main > .div-c-tableList {
			flex-grow: 1;
			overflow: auto;
			padding: 3vh;		
			margin-bottom: 10vh;
			-webkit-overflow-scrolling : touch;
		}
		.tableItem {
			background-repeat: no-repeat;
			background-size: cover;
			background-position: center center;
			color: white;
			width: 22vh;
			height: 20vh;
			position: absolute;
			transform: translateX(-50%) translateY(-50%);
			top: 50%;
			left: 50%;
		}
		.tableItem-wrapper:nth-child(1) .tableItem, .tableItem-wrapper:nth-child(2) .tableItem {
			background-image: url(/img/caizhong/bjl/bjlzm1.png);
		}
		.tableItem-wrapper:nth-child(3) .tableItem, .tableItem-wrapper:nth-child(4) .tableItem {
			background-image: url(/img/caizhong/bjl/bjlzm2.png);
		}
		.tableItem-wrapper:nth-child(5) .tableItem, .tableItem-wrapper:nth-child(6) .tableItem {
			background-image: url(/img/caizhong/bjl/bjlzm3.png);
		}		
		.tableItem-wrapper {
			box-shadow: 0 0 5px rgba(0,0,0,.6), inset 0 0 4px rgba(255,255,255,.3);
			background-color: rgba(255,255,255,.08);
			width: 24vh;
			height: 24vh;
			position: relative;
			border-radius: 10px;
		}
		.tableItem-wrapper > .span-betMoney-text {
			background-color: #0173dd;
			border-radius: 100px;
			width: 80%;
			color: white;
			text-align: center;
			padding: 1vh 0;
			display: inline-block;
			z-index: 2;
			box-shadow: 0 2px 3px rgba(0,0,0,.3), inset 0 0 2px rgba(0,0,0,.3);
			border: 1px solid #cce6ff;
			position: absolute;
			top: 1vh;
			left: 50%;
			transform: translateX(-50%);
		}
		.tableItem > .span-s-tableNumber, .tableItem > p {
			color: #e4d68c;
			position: absolute;
			left: 50%;
			transform: translateX(-50%);
			bottom: 44%;
		}
		.tableItem > p {
			text-align: center;
			bottom: 7%;
			color: black;
			margin-bottom: 0;
			width: 100%;
		}
		.tableItem > p .span-c-roomTime {
			font-weight: bold;
		}
		.tableItem > p span:nth-child(1) {
			margin-right: 6px;
		}
		.tableItem > p span:nth-child(2) {
			color: #8b0000;
		}		
		.div-c-tableList > div {
			float:left;
			margin-bottom:10px;
			width: 46%;
		}
		.div-c-tableList > div:nth-child(odd) {
			margin-left: 2.5%;
			margin-right: 2.5%;
		}
		.clearfix:after {
			content: "";
			display: block;
			clear: both;
		}
		header > .roleBtn {
		 	position: absolute; 
			display: inline-block;
			cursor:pointer;
 			top: 50%;
			transform: translateY(-50%);
 			right: 16px; 
			padding: 0 4px;
			border-radius: 4px;
			border: 1px solid #1456be;
			box-shadow: 0 0 8px #1456be, inset 0 0 21px #1456be, inset 0 0 5px #1456be;
			background: -webkit-linear-gradient(top,#175586,#1a7bb7 58%,#5972fe 80%,#1456be);
		}
		header > .backBtn {
			position: absolute;
 			top: 50%;
			transform: translateY(-50%);
			left:16px;
			padding: 1px 6px;
			border-radius: 4px;
			border: 1px solid #1456be;
			box-shadow: 0 0 8px #1456be, inset 0 0 21px #1456be, inset 0 0 5px #1456be;
			background: -webkit-linear-gradient(top,#175586,#1a7bb7 58%,#5972fe 80%,#1456be);
		}
		#id-div-noticeDiv {
			font-size: 3vh;
		}
		.tableItem-wrapper {
			cursor: pointer;
		}
		.noticeContentInner .main .title {
			position: relative;
		    height: 30px;
		    margin-top: 5px;
		    padding-left: 15px;
		    font-size: 14px;
	        line-height: 30px;
    		font-weight: 700;
		}
		.noticeContentInner .main .title span {
		     margin-left: 10px;
   			 color: #fb0;
		}
		.noticeContentInner .space {
			text-indent:2rem;
		}
		.noticeContentInner .content {
    line-height: 1.8;
    font-size: 1.3rem;
}
.noticeContentInner .line {
	height: 10px;
    border-bottom: 1px solid #ddd;
}
.noticeContentInner .list {
	padding-bottom:10px;
}
.noticeContentInner .list div {
	    position: relative;
    margin-top: 6px;
    padding-left: 20px;
    line-height: 1.5;
    font-size: 12px;
}
.noticeContentInner .list div::after {
    content: " ";
    position: absolute;
    top: 6px;
    left: 7px;
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #aaa;
}
.noticeContentInner .red {
	color: #d32f2f;
}
.noticeContentInner .table {
display: table;
    width: 100%;
    margin: 5px 0;
    border-spacing: 0;
    border-collapse: collapse;
    font-size: 12px;
    text-align: center;	
}
.noticeContentInner .table>div:first-of-type {
	background: #f44336;
    font-size: 13px;
    color: #fff;
}
.noticeContentInner .table>div {
	display:table-row;
}
.noticeContentInner .table>div>div {
    display: table-cell;
    width: 50%;
    font-size:14px;
    line-height: 1.5;
    padding: 4px 5px;
    border: 1px solid #ddd;
    vertical-align: middle;
    word-wrap: break-word;
    word-break: break-all;	
}

		</style>
	</head>
	<body>
	<div class='wapper' id='bjl'>
		 <div class="site-background"></div>
		 <div id="id-div-noticeDiv"></div>
			<div class="div-c-main">
	 		<header class="clearfix">
	 			<button class="btn btn-primary backBtn">返回</button>
	 			<h4>百家乐</h4>
	 			<span class="roleBtn">规则说明</span>
	 		</header>
	 		<div class="div-c-tableList clearfix">
	 			<div class="tableItem-wrapper" id="tableItem-wrapper1">
	 				<span class="span-betMoney-text"></span>
		 			<div class="tableItem">
		 				<span class="span-s-tableNumber">001桌</span>
		 				<p><span class="span-c-roomStatus"></span><span class="span-c-roomTime"></span></p>
		 			</div>
	 			</div>
	 			<div class="tableItem-wrapper" id="tableItem-wrapper2">
	 				<span class="span-betMoney-text"></span>
		 			<div class="tableItem">
		 				<span class="span-s-tableNumber">002桌</span>
		 				<p><span class="span-c-roomStatus"></span><span class="span-c-roomTime"></span></p>
		 			</div>
	 			</div>
	 			<div class="tableItem-wrapper" id="tableItem-wrapper3">
	 				<span class="span-betMoney-text"></span>
		 			<div class="tableItem">
		 				<span class="span-s-tableNumber">003桌</span>
		 				<p><span class="span-c-roomStatus"></span><span class="span-c-roomTime"></span></p>
		 			</div>
	 			</div>
	 			<div class="tableItem-wrapper" id="tableItem-wrapper4">
	 				<span class="span-betMoney-text"></span>
		 			<div class="tableItem">
		 				<span class="span-s-tableNumber">004桌</span>
		 				<p><span class="span-c-roomStatus"></span><span class="span-c-roomTime"></span></p>
		 			</div>
	 			</div>
	 			<div class="tableItem-wrapper" id="tableItem-wrapper5">
	 				<span class="span-betMoney-text"></span>
		 			<div class="tableItem">
		 				<span class="span-s-tableNumber">005桌</span>
		 				<p><span class="span-c-roomStatus"></span><span class="span-c-roomTime"></span></p>
		 			</div>
	 			</div>
	 			<div class="tableItem-wrapper" id="tableItem-wrapper6">
	 				<span class="span-betMoney-text"></span>
		 			<div class="tableItem">
		 				<span class="span-s-tableNumber">006桌</span>
		 				<p><span class="span-c-roomStatus"></span><span class="span-c-roomTime"></span></p>
		 			</div>
	 			</div>
			</div> 
		</div>
	</div>
	</body><script src="/js/common.js"></script>
	<script type="text/javascript">
	$(".backBtn").on("click", function(e) {
		window.location.href = "/gc.do"
	})
	//
	// peilu
	
	
	$(".roleBtn").on("click", function(e) {
		var newRequest = {
				url: "/peilu.do",
				type: "post",
				data: {},
				success: function(data) {
					var newData = JSON.parse(data)
					var zhuang = newData.data.rebate1
					var xian = newData.data.rebate2
					var he = newData.data.rebate5
					var zhuangdui = newData.data.rebate3
					var xiandui = newData.data.rebate4
					showAlertNotice("百家乐规则", '<div class="title">'+
			'简介<span>INTRODUCTION</span></div>'+
	'<div class="content space">'+
			'百家乐源起于意大利，简单的推理和快速运算是百家乐最大特点，因而从十九世纪即为广受欢迎的扑克游戏。</div>'+
		'<div class="line">'+
			'&nbsp;</div>'+
		'<div class="title">'+
		'	玩法<span>GAME INSTRUCTION</span></div>'+
		'<div class="content">'+
		'	游戏使用8副扑克牌：</div>'+
		'<div class="list">'+
		'	<div>'+
		'		荷官会派出“庄家”和“闲家”两份牌。</div>'+
		'	<div>'+
			'A是1点，2到9的牌面即为点数，K、Q、J、10是0点，加起来等于10也当作是0点；总数9点或最接近9点的一家胜出。</div>'+
		'	<div>'+
				'当任何一家起手牌的点数总和为8或9，就称为“天生赢家”，牌局就算结束，双方不再补牌。</div>'+
		'	<div>'+
		'		您有5种下注选择：闲家、庄家、和局、庄对子、闲对子</div>'+
		'	<div>'+
		'		派完起手牌，将依补牌规则补1张牌。</div>'+
		'</div>'+
		'<div class="content">'+
			'补牌规则：</div>'+
		'<div class="content red">'+
			'闲家：</div>'+
	'<div class="table">'+
			'<div>'+
				'<div>'+
				'	起手牌点数总和</div>'+
				'<div>'+
				'	补牌规则</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
				'	0</div>'+
				'<div>'+
				'	须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'1</div>'+
			'<div>'+
					'须补牌</div>'+
		'</div>'+
			'<div>'+
			'	<div>'+
				'	2</div>'+
				'<div>'+
					'须补牌</div>'+
		'</div>'+
			'<div>'+
				'<div>'+
					'3</div>'+
				'<div>'+
					'须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
				'4</div>'+
				'<div>'+
					'须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'5</div>'+
				'<div>'+
					'须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
				'6</div>'+
				'<div>'+
					'不须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'7</div>'+
				'<div>'+
				'不须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
				'8</div>'+
				'<div>'+
					'“天生赢家”</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'9</div>'+
				'<div>'+
					'“天生赢家”</div>'+
			'</div>'+
		'</div>'+
	'<div class="content red">'+
			'庄家：</div>'+
		'<div class="table">'+
			'<div>'+
				'<div>'+
					'起手牌点数总和</div>'+
			'<div>'+
					'补牌规则</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'0</div>'+
			'<div>'+
					'须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'1</div>'+
				'<div>'+
					'须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'2</div>'+
			'<div>'+
					'须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'3</div>'+
				'<div>'+
					'当闲家补得第三张牌是8，不须补牌；其余则须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'4</div>'+
				'<div>'+
					'当闲家补得第三张牌是0.1.8.9，不须补牌；其余则须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'5</div>'+
				'<div>'+
					'当闲家补得第三张牌是0.1.2.3.8.9，不须补牌；其余则须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'6</div>'+
				'<div>'+
					'当闲家补得第三张牌是0.1.2.3.4.5.8.9，不须补牌；其余则须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'7</div>'+
				'<div>'+
					'不须补牌</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'8</div>'+
				'<div>'+
					'“天生赢家”</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'9</div>'+
				'<div>'+
					'“天生赢家”</div>'+
			'</div>'+
		'</div>'+
		'<div class="content red">'+
			'闲家起手牌点数为6点或7点，闲家不须补牌 ，此条件下庄家起手牌点数为5或5点以下，庄家必须补第三张牌。</div>'+
		'<div class="line">'+
			'&nbsp;</div>'+
		'<div class="title">'+
			'派彩<span>PAYOFF</span></div>'+
		'<div class="table">'+
			'<div>'+
				'<div>'+
					'下注组合</div>'+
				'<div>'+
					'赔率</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'庄</div>'+
				'<div id="e-Zhuang">'+
					'1 赔 ' + zhuang  + '</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'闲</div>'+
				'<div id="e-Xian">'+
					'1 赔 ' + xian + '</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'和</div>'+
				'<div id="e-He">'+
					'1 赔 ' + he + '</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'庄对</div>'+
				'<div id="e-ZhuangDui">'+
					'1 赔' + zhuangdui + '</div>'+
			'</div>'+
			'<div>'+
				'<div>'+
					'闲对</div>'+
				'<div id="e-XianDui">'+
					'1 赔 ' + xiandui + '</div>'+
			'</div>'+
		'</div>'+
		'<div class="list">'+
			'<div>'+
				'和局时，“庄／闲”的下注将退回。</div>'+
			'<div>'+
				'庄对指庄的起手牌为同数字或英文字母。</div>'+
			'<div>'+
				'闲对指闲的起手牌为同数字或英文字母。</div>'+
		'</div>', "")
				},
				error: function(status) {
					setNoticeDivHTML("网络繁忙")
				}
			}
		ajax(newRequest)
		
	})
	var TABLE_NUMBER_OBJECT = {
			"1": "",
			"2": "2",
			"3": "3",
			"4": "4",
			"5": "5",
			"6": "6",
	}
	stopUserScaleScreenIOS()
	   
	   var setAllTableData = function(arr) {
		   var allTableDivs = document.querySelectorAll(".tableItem-wrapper")
		   for (var i = 0; i < allTableDivs.length; i++) {
			   var item = allTableDivs[i]
			   var dataItem = arr[i]
			   var minValue = formatString2SimpleString(dataItem.zxje)
			   var maxValue = formatString2SimpleString(dataItem.zdje)
			   var spanElement = item.querySelector(".span-betMoney-text")
			   spanElement.innerHTML = minValue + "-" + maxValue
			   item.dataset.roomid = dataItem.zzid
			   item.dataset.max = dataItem.zdje
			   item.dataset.min = dataItem.zxje
			   item.dataset.index = (i + 1)
		   }
	   } 
	   
	   // 35 ~ 0
	   // 20 秒下注 15秒发牌
	   
	   var autoUpdateStausAndTime = function(parentDiv, time) {
		   var statusSpan = parentDiv.querySelector(".span-c-roomStatus")
		   var timeSpan = parentDiv.querySelector(".span-c-roomTime")
		   var n = Number(time)
		   setInterval(function() {
			   if (n == 0) {
				   n = 45
			   }
			   if (n > 15) {
				   statusSpan.innerHTML = "下注中"
				   timeSpan.innerHTML = n - 15 
				   n = n - 1
			   }
			   else if (n > 0) {
				   statusSpan.innerHTML = "开牌中"
				   timeSpan.innerHTML = n
				   n = n - 1
			   }
		   }, 1000)
	   }
	   
	   var getAllTableTime = function(parentDiv) {
  			var urlPath = "/dsq" + TABLE_NUMBER_OBJECT[parentDiv.dataset.index] + ".do"
				var newRequest = {
					url: urlPath,
					type: "post",
					data: {
						zh: parentDiv.dataset.roomid
					},
					success: function(data) {
						var newData = JSON.parse(data)
						autoUpdateStausAndTime(parentDiv, newData.data)
					},
					error: function(status) {
						console.log("status", status)
					}
				}
			ajax(newRequest)		   
	   }
	    
	   var getAllTableData = function() {
   			var urlPath = "/zzid.do" 
				var newRequest = {
					url: urlPath,
					type: "post",
					data: {},
					success: function(data) {
						var newData = JSON.parse(data)
						setAllTableData(newData.data)
						//for (var i = 1; i < 7; i++) {
						getAllTableTime(document.querySelector("#tableItem-wrapper1"))
						//}
						getAllTableTime(document.querySelector("#tableItem-wrapper2"))
						getAllTableTime(document.querySelector("#tableItem-wrapper3"))
						getAllTableTime(document.querySelector("#tableItem-wrapper4"))
						getAllTableTime(document.querySelector("#tableItem-wrapper5"))
						getAllTableTime(document.querySelector("#tableItem-wrapper6"))
					},
					error: function(status) {
						console.log("status", status)
					}
				}
			ajax(newRequest)
	   }
	   
	   var bindAllCickEvent = function() {
		   var allDivs = document.querySelectorAll(".tableItem-wrapper")
		   for (var i = 0; i < allDivs.length; i++) {
			   var item =allDivs[i]
			   item.addEventListener("click", function(event) {
				   var urlPath ="/Money.do"
						var newRequest = {
							url: urlPath,
							type: "post",
							data: {	},
							success: function(data) {
								var newData = JSON.parse(data)
								var currentMoney = parseFloat(newData.data)
								var parentDiv = $(event.target).closest(".tableItem-wrapper")[0]
								var maxValue = parseFloat(parentDiv.dataset.max)
								var minValue = parseFloat(parentDiv.dataset.min)
								if (currentMoney > maxValue) {
									setNoticeDivHTML("你的金额大于该房间的所要求的最大金额")
									return
								}
								if (currentMoney < minValue) {
									setNoticeDivHTML("你的金额小于该房间的所要求的最小金额")
									return
								}
								location.href = "/bjlindex.do?roomid=" + parentDiv.dataset.roomid + "&index=" + parentDiv.dataset.index 
							},
							error: function(status) {
							}
						}
					ajax(newRequest)
			   })
		   }
	   }

	   var __main = function() {
	      getAllTableData()
	      bindAllCickEvent()
	   }
	   
	   __main()
	
/* 		$(function(){
			$(".div1").click(function(){
				var desk=$(this).attr("class").replace("div1 ","");
				window.location.href="xz.do?id="+$("#id").text()+"&cname="+$("#cname").text()+"&key="+desk;
			});
		}); */
	</script>
</html>
